package com.liuheng.spzx.user.test;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.mail.SimpleMailMessage;
import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.test.context.junit4.SpringRunner;

@RunWith(SpringRunner.class) // 如果使用的是JUnit4
@SpringBootTest
public class test {

    @Autowired
    private JavaMailSender jms;

    @Test
    public void sendMail() {
        SimpleMailMessage mainMessage = new SimpleMailMessage();
        mainMessage.setFrom("2100981240@qq.com");
        mainMessage.setTo("1683842246@qq.com");
        mainMessage.setSubject("邮箱验证");
        String msg = "你好" + "1683842246@qq.com" + "的验证码是8888";
        mainMessage.setText(msg);

        // 注意：在测试环境下，如果不想真正发送邮件，还可以考虑使用Mockito等工具来模拟邮件发送行为
        jms.send(mainMessage);
    }
}